# Maintainer: Luca Weiss <luca@z3ntu.xyz>
# Contributor: Antoni Aloy <aaloytorrens@gmail.com>
pkgname=lomiri-content-hub
pkgver=1.1.0
pkgrel=0
pkgdesc="Content sharing/picking infrastructure and service, designed to allow apps to securely and efficiently exchange content"
url="https://gitlab.com/ubports/development/core/content-hub"
arch="all !armhf" # blocked by lomiri-ui-toolkit-dev
license="GPL-3.0-only AND LGPL-3.0-only"
depends_dev="
	gsettings-qt-dev
	libapparmor-dev
	libnih-dev
	libnotify-dev
	lomiri-app-launch-dev
	lomiri-download-manager-dev
	lomiri-ui-toolkit-dev
	qt5-qtdeclarative-dev
	"
makedepends="
	$depends_dev
	cmake
	cmake-extras
	doxygen
	graphviz
	gtest-dev
	libapparmor
	qt5-qttools-dev
	samurai
	"
checkdepends="
	gmock
	dbus-test-runner
	xvfb-run
	"
source="https://gitlab.com/ubports/development/core/content-hub/-/archive/$pkgver/content-hub-$pkgver.tar.gz
	qdoc.patch
	qmlplugindump.patch
	"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
builddir="$srcdir/content-hub-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		-DWerror=OFF
	cmake --build build
}

check() {
	# Some app_hub_communication_* tests require some custom dbus extension
	# (GetConnectionAppArmorSecurityContext).
	xvfb-run ctest --test-dir build --output-on-failure \
		-E 'app_hub_communication_store_migration|app_hub_communication_transfer|app_hub_communication_handler'
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Remove files for testing only
	# https://gitlab.com/ubports/development/core/content-hub/-/blob/main/debian/content-hub-testability.install
	rm "$pkgdir"/usr/bin/content-hub-test*
	rm "$pkgdir"/usr/share/content-hub/peers/content-hub-test*
	rm "$pkgdir"/usr/share/applications/content-hub-test*
	rm -r "$pkgdir"/usr/share/content-hub/testability/data
	rm "$pkgdir"/usr/share/icons/hicolor/512x512/apps/content-hub-test*
}

sha512sums="
c99f55b78dc41cf220121f18f0ad64c02d0a3d0a61209b7ac3187c95569ad9c0ce4eeebb84f5cc4ba4da09c4eb03b4418e01804c376dc172bac094c1d2498e34  content-hub-1.1.0.tar.gz
32f307cbe1418842315080627240e9b2fe0ea26c96197da446d2a239a19c947a91fbf242a87d8ebb2b6d4f729e8ce2adc71b3592513d14479e39b45ce7d0085e  qdoc.patch
639a3b2ea44d436f0a5e61dae77a71e7650b8d5a0073e5f04d0af0ac3060675cf93c927f5cfddfabc09866a7b5ab36810a109597ae3cc43865e5b1680c5a9b28  qmlplugindump.patch
"
